---
category: Date Time
created: '2021-02-25'
title: Get the last date in the month of a date
updated: '2021-10-13'
---

**JavaScript version**

```js getLastDate.js
const getLastDate = (d = new Date()) => new Date(d.getFullYear(), d.getMonth() + 1, 0);
```

**TypeScript version**

```ts getLastDate.ts
const getLastDate = (d = new Date()): Date => new Date(d.getFullYear(), d.getMonth() + 1, 0);
```
